// 防抖：高频触发的时候，只触发一次

const debounce = (fn, wait = 100) => {
  let timeId = null;

  return (...args) => {
    if (timeId) {
      clearTimeout(timeId);
      timeId = null;
    }
    timeId = setTimeout(() => {
      fn.apply(this, args);
    }, wait);
  };
};


function logScroll() {
    console.log('滚动屏幕')
}

window.addEventListener('scroll', debounce(logScroll, 500))